go/types.Checker.errorf (method)

173 uses

	go/types (current package)
		assignments.go#L30: 		check.errorf(x, 0, "cannot assign %s to %s in %s", x, T, context)
		assignments.go#L43: 				check.errorf(x, _UntypedNil, "use of untyped nil in %s", context)
		assignments.go#L76: 		check.errorf(x, _WrongTypeArgCount, "cannot use generic function %s without instantiation in %s", x, context)
		assignments.go#L90: 				check.errorf(x, code, "cannot use %s as type %s in %s:\n\t%s", x, T, context, reason)
		assignments.go#L92: 				check.errorf(x, code, "cannot use %s as type %s in %s", x, T, context)
		assignments.go#L96: 				check.errorf(x, code, "cannot use %s as %s value in %s: %s", x, T, context, reason)
		assignments.go#L98: 				check.errorf(x, code, "cannot use %s as %s value in %s", x, T, context)
		assignments.go#L115: 		check.errorf(x, _InvalidConstInit, "%s is not constant", x)
		assignments.go#L150: 				check.errorf(x, _UntypedNil, "use of untyped nil in %s", context)
		assignments.go#L225: 				check.errorf(&z, _UnaddressableFieldAssign, "cannot assign to struct field %s in map", ExprString(z.expr))
		assignments.go#L229: 		check.errorf(&z, _UnassignableOperand, "cannot assign to %s", &z)
		assignments.go#L307: 			check.errorf(rhs0, _WrongAssignCount, "assignment mismatch: %s but %s returns %s", vars, call.Fun, vals)
		assignments.go#L311: 	check.errorf(rhs0, _WrongAssignCount, "assignment mismatch: %s but %s", vars, vals)
		assignments.go#L342: 			check.errorf(at, _WrongResultCount, "%s return values\n\thave %s\n\twant %s",
		assignments.go#L352: 			check.errorf(rhs[0], _WrongAssignCount, "cannot initialize %d variables with %d values", len(lhs), len(rhs))
		assignments.go#L390: 			check.errorf(rhs[0], _WrongAssignCount, "cannot assign %d values to %d variables", len(rhs), len(lhs))
		assignments.go#L423: 			check.errorf(lhs, _BadDecl, "non-name %s on left side of :=", lhs)
		assignments.go#L431: 				check.errorf(lhs, _RepeatedDecl, "%s repeated on left side of :=", lhs)
		assignments.go#L448: 				check.errorf(lhs, _UnassignableOperand, "cannot assign to %s", lhs)
		builtins.go#L103: 			check.errorf(x, _InvalidAppend, "first argument to append must be a slice; %s", cause)
		builtins.go#L372: 			check.errorf(x, _InvalidCopy, "arguments to copy %s and %s have different element types %s and %s", x, &y, dst.elem, src.elem)
		builtins.go#L504: 			check.errorf(arg0, _InvalidMake, "cannot make %s: no core type", arg0)
		builtins.go#L608: 			check.errorf(call.Fun, _InvalidUnsafeAdd, "unsafe.Add requires go1.17 or later")
		builtins.go#L734: 			check.errorf(call.Fun, _InvalidUnsafeSlice, "unsafe.Slice requires go1.17 or later")
		builtins.go#L765: 			check.errorf(x, _Test, "internal error: value of %s should be a boolean constant", x)
		builtins.go#L769: 			check.errorf(call, _Test, "%v failed", call)
		call.go#L36: 		check.errorf(ix.Indices[got-1], _WrongTypeArgCount, "got %d type arguments but want %d", got, want)
		call.go#L132: 			check.errorf(inNode(call, call.Rparen), _WrongArgCount, "missing argument in conversion to %s", T)
		call.go#L137: 					check.errorf(call.Args[0], _BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T)
		call.go#L142: 						check.errorf(call, _MisplacedConstraintIface, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T)
		call.go#L150: 			check.errorf(call.Args[n-1], _WrongArgCount, "too many arguments in conversion to %s", T)
		call.go#L199: 			check.errorf(xlist[want], _WrongTypeArgCount, "got %d type arguments but want %d", got, want)
		call.go#L295: 			check.errorf(a, 0, "%s used as value", a)
		call.go#L323: 				check.errorf(inNode(call, call.Ellipsis), _InvalidDotDotDot, "cannot use ... with %d-valued %s", nargs, call.Args[0])
		call.go#L350: 			check.errorf(inNode(call, call.Ellipsis), _NonVariadicDotDotDot, "cannot use ... in call to non-variadic %s", call.Fun)
		call.go#L371: 		check.errorf(at, _WrongArgCount, "%s arguments in call to %s\n\thave %s\n\twant %s",
		call.go#L473: 					check.errorf(e.Sel, _UndeclaredImportedName, "%s not declared by package C", sel)
		call.go#L481: 						check.errorf(e.Sel, _UndeclaredImportedName, "%s not declared by package %s", sel, pkg.name)
		call.go#L486: 					check.errorf(e.Sel, _UnexportedName, "%s not exported by package %s", sel, pkg.name)
		call.go#L539: 		check.errorf(e.Sel, _UncalledBuiltin, "cannot select on %s", x)
		call.go#L554: 			check.errorf(e.Sel, _AmbiguousSelector, "ambiguous selector %s.%s", x.expr, sel)
		call.go#L559: 			check.errorf(e.Sel, _InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ)
		call.go#L584: 		check.errorf(e.Sel, _MissingFieldOrMethod, "%s.%s undefined (%s)", x.expr, sel, why)
		call.go#L598: 			check.errorf(e.Sel, _MissingFieldOrMethod, "%s.%s undefined (type %s has no method %s)", x.expr, sel, x.typ, sel)
		check.go#L279: 				check.errorf(file.Name, _BlankPkgName, "invalid package name _")
		check.go#L287: 			check.errorf(atPos(file.Package), _MismatchedPkgName, "package %s; expected %s", name, pkg.name)
		conversions.go#L77: 				check.errorf(x, _InvalidConversion, "cannot convert %s to type %s:\n\t%s", x, T, cause)
		conversions.go#L79: 				check.errorf(x, _InvalidConversion, "cannot convert %s to type %s", x, T)
		conversions.go#L83: 				check.errorf(x, _InvalidConversion, "cannot convert %s to %s (%s)", x, T, cause)
		conversions.go#L85: 				check.errorf(x, _InvalidConversion, "cannot convert %s to %s", x, T)
		decl.go#L19: 		check.errorf(obj, _DuplicateDecl, "\tother declaration of %s", obj.Name()) // secondary error, \t indented
		decl.go#L30: 			check.errorf(obj, _DuplicateDecl, "%s redeclared in this block", obj.Name())
		decl.go#L316: 		check.errorf(obj, _InvalidDeclCycle, "invalid recursive type %s", obj.Name())
		decl.go#L318: 		check.errorf(obj, _InvalidDeclCycle, "illegal cycle in declaration of %s", obj.Name())
		decl.go#L321: 		check.errorf(obj, _InvalidDeclCycle, "\t%s refers to", obj.Name()) // secondary error, \t indented
		decl.go#L328: 	check.errorf(obj, _InvalidDeclCycle, "\t%s", obj.Name())
		decl.go#L438: 				check.errorf(typ, _InvalidConstType, "invalid constant type %s", t)
		decl.go#L543: 			check.errorf(tdecl.Type, _UnsupportedFeature, "using type constraint %s requires go1.18 or later", rhs)
		decl.go#L558: 			check.errorf(atPos(tdecl.Assign), _BadDecl, "type aliases requires go1.9 or later")
		decl.go#L738: 			check.errorf(m, _DuplicateMethod, "method %s already declared for %s", m.name, obj)
		decl.go#L770: 					check.errorf(alt, _DuplicateFieldAndMethod, "field and method with the same name %s", fld.name)
		errors.go#L218: func (check *Checker) errorf(at positioner, code errorCode, format string, args ...any) {
		errors.go#L227: 	check.errorf(at, 0, "invalid AST: "+format, args...)
		errors.go#L231: 	check.errorf(at, code, "invalid argument: "+format, args...)
		errors.go#L235: 	check.errorf(at, code, "invalid operation: "+format, args...)
		expr.go#L97: 		check.errorf(atPos(opPos), _InvalidConstVal, "constant result is not representable")
		expr.go#L113: 		check.errorf(atPos(opPos), _InvalidConstVal, "constant %s overflow", opName(x.expr))
		expr.go#L463: 	check.errorf(x, code, msg, x, target)
		expr.go#L842: 		check.errorf(x, code, "invalid case %s in switch on %s (%s)", x.expr, y.expr, cause) // error position always at 1st operand
		expr.go#L1237: 		check.errorf(x.expr, _WrongTypeArgCount, "cannot use generic %s %s without instantiation", what, x.expr)
		expr.go#L1280: 				check.errorf(e, _InvalidConstVal, "excessively long constant: %s... (%d chars)", e.Value[:10], len(e.Value))
		expr.go#L1290: 			check.errorf(e, _InvalidConstVal, "malformed constant: %s", e.Value)
		expr.go#L1343: 				check.errorf(e, _InvalidLit, "invalid composite literal element type %s: no core type", typ)
		expr.go#L1379: 						check.errorf(kv, _InvalidLitField, "invalid field name %s in struct literal", kv.Key)
		expr.go#L1384: 						check.errorf(kv, _MissingLitField, "unknown field %s in struct literal", key.Name)
		expr.go#L1393: 						check.errorf(kv, _DuplicateLitField, "duplicate field name %s in struct literal", key.Name)
		expr.go#L1413: 						check.errorf(x,
		expr.go#L1500: 						check.errorf(x, _DuplicateLitKey, "duplicate key %s in map literal", x.val)
		expr.go#L1522: 				check.errorf(e, _InvalidLit, "invalid composite literal type %s", typ)
		expr.go#L1693: 		check.errorf(e, _ImpossibleAssert, "impossible type switch case: %s\n\t%s cannot have dynamic type %s %s", e, x, T, cause)
		expr.go#L1697: 	check.errorf(e, _ImpossibleAssert, "impossible type assertion: %s\n\t%s does not implement %s %s", e, T, x.typ, cause)
		expr.go#L1761: 		check.errorf(x, code, msg, x)
		expr.go#L1773: 				check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
		expr.go#L1775: 				check.errorf(x, _TooManyValues, "%d-valued %s where single value is expected", t.Len(), x)
		index.go#L320: 					check.errorf(at, _SwappedSliceIndices, "invalid slice indices: %d < %d", y, x)
		index.go#L428: 					check.errorf(e, _InvalidLitIndex, "index %s must be integer constant", kv.Key)
		index.go#L433: 			check.errorf(e, _OversizeArrayLit, "index %d is out of bounds (>= %d)", index, length)
		index.go#L441: 				check.errorf(e, _DuplicateLitKey, "duplicate index %d in array or slice literal", index)
		infer.go#L222: 				check.errorf(arg, _CannotInferTypeArgs, "%s %s of %s does not match %s (cannot infer %s)", kind, targ, arg.expr, tpar, typeParamsString(tparams))
		infer.go#L234: 			check.errorf(arg, _CannotInferTypeArgs, "%s %s of %s does not match inferred type %s for %s", kind, targ, arg.expr, inferred, tpar)
		infer.go#L236: 			check.errorf(arg, _CannotInferTypeArgs, "%s %s of %s does not match %s", kind, targ, arg.expr, tpar)
		infer.go#L326: 	check.errorf(posn, _CannotInferTypeArgs, "cannot infer %s (%v)", tpar.obj.name, tpar.obj.pos)
		infer.go#L539: 						check.errorf(posn, _InvalidTypeArg, "%s does not match %s%s", tpar, tilde, core.typ)
		initorder.go#L155: 	check.errorf(obj, _InvalidInitCycle, "initialization cycle for %s", obj.Name())
		initorder.go#L158: 		check.errorf(obj, _InvalidInitCycle, "\t%s refers to", obj.Name()) // secondary error, \t indented
		initorder.go#L162: 	check.errorf(obj, _InvalidInitCycle, "\t%s", obj.Name())
		instantiate.go#L128: 			check.errorf(atPos(pos), _WrongTypeArgCount, "got %d arguments but %d type parameters", ntargs, ntparams)
		interface.go#L177: 			check.errorf(name, _BlankIfaceMethod, "invalid method name _")
		interface.go#L198: 			check.errorf(at, _InvalidMethodTypeParams, "methods cannot have type parameters")
		labels.go#L35: 		check.errorf(jmp.Label, code, msg, name)
		labels.go#L195: 					check.errorf(s.Label, _MisplacedLabel, "invalid break label %s", name)
		labels.go#L210: 					check.errorf(s.Label, _MisplacedLabel, "invalid continue label %s", name)
		mono.go#L141: 	check.errorf(obj0, _InvalidInstanceCycle, "instantiation cycle:")
		mono.go#L152: 			check.errorf(atPos(edge.pos), _InvalidInstanceCycle, "\t%s implicitly parameterized by %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented
		mono.go#L154: 			check.errorf(atPos(edge.pos), _InvalidInstanceCycle, "\t%s instantiated as %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented
		resolver.go#L65: 			check.errorf(s, code, "missing type or init expr")
		resolver.go#L71: 			check.errorf(n, code, "extra init expr %s", n)
		resolver.go#L75: 			check.errorf(s, code, "extra init expr at %s", check.fset.Position(init.Pos()))
		resolver.go#L80: 		check.errorf(n, code, "missing init expr for %s", n)
		resolver.go#L109: 		check.errorf(ident, _InvalidInitDecl, "cannot declare init - must be func")
		resolver.go#L116: 		check.errorf(ident, _InvalidMainDecl, "cannot declare main - must be func")
		resolver.go#L174: 			check.errorf(at, _BrokenImport, "could not import %s (%s)", path, err)
		resolver.go#L258: 					check.errorf(d.spec.Path, _BadImportPath, "invalid import path (%s)", err)
		resolver.go#L273: 						check.errorf(d.spec.Name, _ImportCRenamed, `cannot rename import "C"`)
		resolver.go#L279: 					check.errorf(d.spec, _InvalidInitDecl, "cannot import package as init - init must be a func")
		resolver.go#L325: 								check.errorf(d.spec.Name, _DuplicateDecl, "%s redeclared in this block", alt.Name())
		resolver.go#L462: 					check.errorf(alt, _DuplicateDecl, "%s already declared through import of %s", alt.Name(), pkg.Imported())
		resolver.go#L465: 					check.errorf(alt, _DuplicateDecl, "%s already declared through dot-import of %s", alt.Name(), obj.Pkg())
		resolver.go#L530: 					check.errorf(arg, _BadDecl, "receiver type parameter %s must be an identifier", arg)
		signature.go#L161: 				check.errorf(recvPar, _BadRecv, "got %s, but receiver base type declares %d", got, len(recvTParams))
		signature.go#L172: 			check.errorf(ftyp.TypeParams, _InvalidMethodTypeParams, "methods cannot have type parameters")
		signature.go#L184: 		check.errorf(obj, _DuplicateDecl, "%s redeclared in this block", obj.Name())
		signature.go#L221: 						check.errorf(recv, _InvalidRecv, "cannot define methods on instantiated type %s", recv.typ)
		signature.go#L230: 							check.errorf(recv, _InvalidRecv, "cannot define new methods on non-local type %s", recv.typ)
		signature.go#L256: 						check.errorf(recv, _InvalidRecv, "cannot define new methods on non-local type %s", recv.typ)
		signature.go#L260: 					check.errorf(recv, _InvalidRecv, "invalid receiver type %s", recv.typ)
		signature.go#L263: 					check.errorf(recv, _InvalidRecv, "invalid receiver type %s (%s)", recv.typ, err)
		stmt.go#L147: 				check.errorf(d, _DuplicateDefault, "multiple defaults (first at %s)", check.fset.Position(first.Pos()))
		stmt.go#L192: 	check.errorf(&x, code, "%s %s %s", keyword, msg, &x)
		stmt.go#L264: 					check.errorf(&v, _DuplicateCase, "duplicate case %s in expression switch", &v)
		stmt.go#L308: 				check.errorf(e, _DuplicateCase, "duplicate case %s in type switch", Ts)
		stmt.go#L412: 		check.errorf(&x, code, "%s %s", &x, msg)
		stmt.go#L483: 				check.errorf(inNode(s, s.TokPos), _MultiValAssignOp, "assignment operation %s requires single-valued expressions", s.Tok)
		stmt.go#L515: 					check.errorf(s, _OutOfScopeResult, "result parameter %s not in scope at return", obj.name)
		stmt.go#L516: 					check.errorf(alt, _OutOfScopeResult, "\tinner declaration of %s", obj)
		stmt.go#L596: 				check.errorf(&x, _InvalidExprSwitch, "cannot switch on %s (%s is not comparable)", &x, x.typ)
		stmt.go#L690: 			check.errorf(&x, _InvalidTypeSwitch, "cannot use type switch on type parameter value %s", &x)
		stmt.go#L695: 				check.errorf(&x, _InvalidTypeSwitch, "%s is not an interface", &x)
		struct.go#L200: 		check.errorf(atPos(pos), _DuplicateDecl, "%s redeclared", obj.Name())
		typeset.go#L232: 			check.errorf(atPos(pos), _DuplicateDecl, "duplicate method %s", m.name)
		typeset.go#L233: 			check.errorf(atPos(mpos[other.(*Func)]), _DuplicateDecl, "\tother declaration of %s", m.name) // secondary error, \t indented
		typeset.go#L248: 					check.errorf(atPos(pos), _DuplicateDecl, "duplicate method %s", m.name)
		typeset.go#L249: 					check.errorf(atPos(mpos[other.(*Func)]), _DuplicateDecl, "\tother declaration of %s", m.name) // secondary error, \t indented
		typeset.go#L279: 				check.errorf(atPos(pos), _UnsupportedFeature, "embedding constraint interface %s requires go1.18 or later", typ)
		typeset.go#L289: 				check.errorf(atPos(pos), _InvalidIfaceEmbed, "embedding interface element %s requires go1.18 or later", u)
		typeset.go#L304: 				check.errorf(atPos(pos), _InvalidIfaceEmbed, "embedding non-interface type %s requires go1.18 or later", typ)
		typeset.go#L424: 				check.errorf(atPos(pos), _InvalidUnion, "cannot handle more than %d union terms (implementation limitation)", maxTermCount)
		typexpr.go#L42: 			check.errorf(e, _UndeclaredName, "undeclared name: %s", e.Name)
		typexpr.go#L47: 			check.errorf(e, _UndeclaredName, "undeclared name: %s (requires version go1.18 or later)", e.Name)
		typexpr.go#L78: 		check.errorf(e, _InvalidPkgUse, "use of package %s not in selector", obj.name)
		typexpr.go#L88: 				check.errorf(e, _InvalidIota, "cannot use iota outside constant declaration")
		typexpr.go#L100: 			check.errorf(e, _InvalidDeclCycle, "invalid use of type alias %s in recursive type (see issue #50729)", obj.name)
		typexpr.go#L185: 		check.errorf(e, _WrongTypeArgCount, "cannot use generic type %s without instantiation", typ)
		typexpr.go#L254: 			check.errorf(&x, _NotAType, "%s used as type", &x)
		typexpr.go#L256: 			check.errorf(&x, _NotAType, "%s is not a type", &x)
		typexpr.go#L271: 			check.errorf(&x, _NotAType, "%s used as type", &x)
		typexpr.go#L273: 			check.errorf(&x, _NotAType, "%s is not a type", &x)
		typexpr.go#L357: 				check.errorf(e.Key, _IncomparableMapKey, "incomparable map key type %s%s", typ.key, why)
		typexpr.go#L385: 		check.errorf(e0, _NotAType, "%s is not a type", e0)
		typexpr.go#L505: 			check.errorf(name, _InvalidArrayLen, "undeclared name %s for array length", name.Name)
		typexpr.go#L509: 			check.errorf(name, _InvalidArrayLen, "invalid array length %s", name.Name)
		typexpr.go#L518: 			check.errorf(&x, _InvalidArrayLen, "array length %s must be constant", &x)
		typexpr.go#L529: 				check.errorf(&x, _InvalidArrayLen, "invalid array length %s", &x)
		typexpr.go#L535: 	check.errorf(&x, _InvalidArrayLen, "array length %s must be integer", &x)
		union.go#L70: 				check.errorf(x, _InvalidUnion, "cannot handle more than %d union terms (implementation limitation)", maxTermCount)
		union.go#L100: 					check.errorf(tlist[i], _InvalidUnion, "invalid use of ~ (%s is an interface)", t.typ)
		union.go#L105: 					check.errorf(tlist[i], _InvalidUnion, "invalid use of ~ (underlying type of %s is %s)", t.typ, u)
		union.go#L118: 					check.errorf(tlist[i], _InvalidUnion, "cannot use %s in union (%s contains methods)", t, t)
		union.go#L122: 					check.errorf(tlist[i], _InvalidUnion, "cannot use %s in union (%s embeds comparable)", t, t)
		version.go#L25: 		check.errorf(lit, _InvalidLit, "underscores in numeric literals requires go1.13 or later")
		version.go#L33: 		check.errorf(lit, _InvalidLit, "binary literals requires go1.13 or later")
		version.go#L37: 		check.errorf(lit, _InvalidLit, "0o/0O-style octal literals requires go1.13 or later")
		version.go#L41: 		check.errorf(lit, _InvalidLit, "hexadecimal floating-point literals requires go1.13 or later")